#ifndef STRAY_RESOURCE_MANAGER_H
#define STRAY_RESOURCE_MANAGER_H

#include <Common.h>
#include <File\FileSystem.h>
#include <Object/Singleton.h>
#include <SmartPtr/SharedPtr.h>
#include <Thread/ThreadPool.h>
#include <Graphics/Device.h>
#include "Material/Material.h"
#include "Mesh/Mesh.h"

namespace Stray {
namespace Resource {
	
struct InitParam
{
	Stray::Core::Graphics::DevicePtr spGraphicsDevice_;
	Stray::Core::ThreadPoolPtr spLoadingThreadPool_;
	Stray::Core::ThreadPoolPtr spGraphicsObjectCreatingThreadPool_;
	Stray::Core::Path resourceDir_;
};

class ResourceManagerImpl
{
	friend class Stray::SingletonHolder<ResourceManagerImpl>;
	typedef Stray::Core::Graphics::DevicePtr DevicePtr;
	typedef Stray::Core::ThreadPoolPtr ThreadPoolPtr;
	typedef Stray::Core::Path Path;
public:
	void initialize(const InitParam& param)
	{
		spGraphicsDevice_ = param.spGraphicsDevice_;
		spLoadingThreadPool_ = param.spLoadingThreadPool_;
		spGraphicsObjectCreatingThreadPool_ = param.spGraphicsObjectCreatingThreadPool_;
		resourceDir_ = param.resourceDir_;
	}
	void terminate();

	DevicePtr getGraphicsDevice() const
	{
		return spGraphicsDevice_;
	}

	ThreadPoolPtr getLoadingThreadPool() const
	{
		return spLoadingThreadPool_;
	}

	ThreadPoolPtr getGraphicsObjectCreatingThreadPool() const
	{
		return spGraphicsObjectCreatingThreadPool_;
	}

	Path getResourceDir() const
	{
		return resourceDir_;
	}

	MaterialPtr getMaterial(const ResourceID& id) const
	{
		return MaterialPtr();
	};

	MeshPtr getMesh(const ResourceID& id) const
	{
		return MeshPtr();
	}

	TexturePtr getTexture(const ResourceID& id)
	{
		return TexturePtr();
	}

private:
	Stray::Bool hasInitialized_;
	Stray::Core::Graphics::DevicePtr spGraphicsDevice_;
	ThreadPoolPtr spLoadingThreadPool_;
	ThreadPoolPtr spGraphicsObjectCreatingThreadPool_;
	Stray::Core::Path resourceDir_;
private:
	ResourceManagerImpl():hasInitialized_(Stray::B_FALSE){}
	ResourceManagerImpl(const ResourceManagerImpl&);
	~ResourceManagerImpl(){}
	const ResourceManagerImpl& operator =(const ResourceManagerImpl&);
};

typedef Stray::SingletonHolder<ResourceManagerImpl> ResourceManager;

}
}

#endif